<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateShopDecorateTable extends Migrator
{
    /**
     * Migrate Up.
     */
    public function up()
    {
        $table = $this->table('shop_decorate', ['comment' => '装修模板', 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci']);
        $table->addColumn('name', 'string', ['limit' => 100, 'comment' => '名称'])
            ->addColumn(Column::enum('type', ['template', 'diypage', 'designer'])->setDefault('template')->setComment('模板类型:template=店铺模板,diypage=自定义页面,designer=设计师模板'))    
            ->addColumn('memo', 'string', ['limit' => 255, 'null' => true, 'default' => null, 'comment' => '备注'])
            ->addColumn('platform', 'string', ['limit' => 255, 'null' => true, 'default' => null, 'comment' => '支持平台'])
            ->addColumn(Column::enum('status', ['enable', 'disabled'])->setDefault('disabled')->setComment('状态:normal=启用,disabled=禁用'))
            ->addColumn('create_time', 'integer', ['limit'  =>  10, 'null' => true, 'default' => null, 'comment' => '创建时间'])
            ->addColumn('update_time', 'integer', ['limit'  => 10, 'null' => true, 'default' => null, 'comment' => '更新时间'])
            ->addColumn('delete_time', 'integer', ['limit'  => 10, 'null' => true, 'default' => null, 'comment' => '删除时间'])
            ->create();

        $table = $this->table('shop_decorate_page', ['comment' => '模板数据', 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci']);
        $table->addColumn('decorate_id', 'integer', ['limit' =>  11, 'default' => 0, 'comment' => '模板'])
            ->addColumn('type', 'string', ['limit' => 10, 'comment' => '类型'])
            ->addColumn(Column::longText('page')->setComment('数据'))
            ->addColumn(Column::longText('image')->setNullable()->setComment('截图'))
            ->create();
    }


    /**
     * Migrate Down.
     */
    public function down()
    {
        // 优惠券
        $table = $this->table('shop_decorate');
        $table->drop();

        // 用户优惠券
        $table = $this->table('shop_decorate_page');
        $table->drop();
    }




}
